#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int DigitSum(int n)
{
	while (n > 9)
	{
		return n % 10 + DigitSum(n / 10);
	}
	return n;
}

int main()
{
	int num = 0;
	scanf("%d", &num);
	int ret = DigitSum(num);
	printf("%d", ret);
	return 0;
}